home *** CD-ROM | disk | FTP | other *** search
Text File | 2000-09-28 | 3.5 KB | 121 lines | [TEXT/CWIE] |
- {
- File: TickAnimate.p
-
- Contains: This uses ticks to time and speed control a very simple animation
-
- Written by:
-
- Copyright: Copyright © 1984-1999 by Apple Computer, Inc., All Rights Reserved.
-
- You may incorporate this Apple sample source code into your program(s) without
- restriction. This Apple sample source code has been provided "AS IS" and the
- responsibility for its operation is yours. You are not permitted to redistribute
- this Apple sample source code as "Apple sample source code" after having made
- changes. If you're going to re-distribute the source, we require that you make
- it clear in the source that the code was descended from Apple sample source
- code, but that you've made changes.
-
- Change History (most recent first):
- 7/14/1999 Karl Groethe Updated for Metrowerks Codewarror Pro 2.1
-
-
- }
- PROGRAM ReleaseTst;
-
- USES Quickdraw,Memory,ToolUtils,Resources,Dialogs,OSUtils,Retrace,Fonts,Events,
- Windows,menus;
-
- CONST
- iAnimate = 1;
- iQuit = 2;
- iUser1 = 3;
- iUser2 = 4;
-
- VAR
- MyDialog : DialogPtr;
- theRect : rect;
- animating,quit : boolean;
- Counter : byte;
- item : handle;
- err,itemType,itemHit : integer;
- CurTicks : longint;
- theEvent : EventRecord;
-
- {------------------------------------------------------------------------------------}
-
- PROCEDURE InitMac;
-
- BEGIN {InitMac}
-
- InitGraf(@qd.thePort); {initialize QuickDraw}
- InitFonts; {initialize Font Manager}
- FlushEvents(everyEvent, 0); {call OS Event Mgr to discard any previous events}
- InitWindows; {initialize Window Manager}
- InitMenus; {initialize Menu Manager}
- TEInit; {initialize TextEdit}
- InitDialogs(NIL); {initialize Dialog Manager}
- InitCursor; {call QuickDraw to make cursor (pointer) an arrow}
- quit := false; {always initialize them booleans!}
- animating := false;
- Counter := $21;
-
- END; {InitMac}
-
- {------------------------------------------------------------------------------------}
-
- BEGIN {main PROGRAM}
-
- InitMac;
- MyDialog := GetNewDialog (1,nil,pointer(-1));
- if MyDialog <> nil then
- begin
- SetPort(MyDialog);
- GetDialogItem (MyDialog,iUser1,itemType,item,theRect);
- FrameRect (theRect);
- TextFont (kFontIDHelvetica);
- TextSize (14);
- moveTo ((theRect.topleft.h)+10,(theRect.topleft.v)+15);
- DrawString ('Welcome To TickAnimator');
- GetDialogItem (MyDialog,iUser2,itemType,item,theRect);
- FrameRect (theRect);
- insetRect (theRect,3,3);
- TextFont (kFontIDHelvetica);
- TextSize (24);
- moveTo ((theRect.topleft.h)+10,(theRect.topleft.v)+20);
- DrawString ('Cameron Birse - 1990');
- SetFontLock (true);
- err := noerr;
- CurTicks := tickcount;
- repeat
- if WaitNextEvent (EveryEvent,theEvent,1,nil) then
- if isDialogEvent (theEvent) then
- if DialogSelect (theEvent,MyDialog,itemHit) then
- case itemHit of
- iAnimate : if not animating then animating := true else
- if animating then
- begin
- eraseRect (theRect);
- moveTo ((theRect.topleft.h)+10,(theRect.topleft.v)+20);
- DrawString ('Cameron Birse - 1990');
- animating := false;
- end;
- iQuit : quit := true;
- end; {case}
- if CurTicks < (TickCount-8) then
- begin
- CurTicks := TickCount;
- if animating then
- begin
- eraseRect (theRect);
- moveTo ((theRect.topleft.h)+10,(theRect.topleft.v)+20);
- DrawChar (char(Counter));
- Counter := Counter + 1;
- if Counter > $AA then Counter := $21;
- end;
- end;
- until quit;
- SetFontLock (false);
- TextFont (systemFont);
- TextSize (12);
- end;
- END.